import java.util.Scanner;

public class FCTRL2 {
	public static final int MAX_INPUT_LENGTH = 200;

	public static void display(int num[]) {
		int i = 0;
		for (; (i < num.length) && (num[i] == 0); i++)
			;
		for (; (i < num.length); i++)
			System.out.print(num[i]);
		System.out.println();
	}

	public static void main(String args[]) {
		int testcase, largestNum = 0;
		Scanner in = new Scanner(System.in);
		testcase = in.nextInt();
		int numbers[] = new int[testcase];
		for (int i = 0; i < testcase; i++) {
			numbers[i] = in.nextInt();
			if (numbers[i] > largestNum) {
				largestNum = numbers[i];
			}
		}
		int factorial[][] = new int[largestNum + 1][MAX_INPUT_LENGTH];
		factorial[1][MAX_INPUT_LENGTH - 1] = 1;
		for (int i = 2; i <= largestNum; i++) {
			factorial[i] = multiplyFactorial(factorial[i - 1], i);
		}
		for (int i = 0; i < numbers.length; i++) {
			display(factorial[numbers[i]]);
		}
		in.close();
	}

	private static int[] multiplyFactorial(int[] arrayNum, int intNum) {
		int multipleResult[] = new int[MAX_INPUT_LENGTH];
		for (int i = 0; intNum > 0; intNum /= 10, i++) {
			int index = (MAX_INPUT_LENGTH - 1 - i);
			int moduloNumber = (intNum % 10);
			int shift = 0;
			for (int j = (MAX_INPUT_LENGTH - 1); (index - 1 - shift) > 0; j--) {
				int multiplyRes = (arrayNum[j] * moduloNumber);
				if (multiplyRes > 9) {
					multipleResult[index - 1 - shift] += (multiplyRes / 10);
				}
				multipleResult[index - shift] += (multiplyRes % 10);
				if (multipleResult[index - shift] > 9) {
					multipleResult[index - 1 - shift] += (multipleResult[index
							- shift] / 10);
					multipleResult[index - shift] %= 10;
				}
				shift++;
			}
		}
		return multipleResult;
	}
}
